<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/10/29
  Time: 10:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<h1>注册</h1>

<form action="${pageContext.request.contextPath}/regist" method="post">

    <p> 用户名: <input type="text" name="username" id="username" onchange="cunzai(this)"/> </p>
    <p> 密码: <input type="password" name="password" id="password"/> </p>

    <p> <input type="submit" value="注册"/></p>

</form>

</body>

<script src="${pageContext.request.contextPath}/js/jquery-1.12.4.min.js"></script>
<script>

    function cunzai(obj) {
        //alert("aaaaaaaaaaaaaaaaaa")
        $.ajax({
            url:"${pageContext.request.contextPath}/findUser",
            method:"post",
            data: "username="+$(obj).val(),
            success:function(result){
                $(obj).nextAll().remove();
                $(obj).parent().append(result)
            }
        })
    }
</script>
</html>
